/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package transervfx.Dato.Entidad;

import java.io.Serializable;
import java.util.ArrayList;
import javafx.beans.property.adapter.JavaBeanBooleanProperty;
import javafx.beans.property.adapter.JavaBeanBooleanPropertyBuilder;
import javafx.beans.property.adapter.JavaBeanIntegerProperty;
import javafx.beans.property.adapter.JavaBeanIntegerPropertyBuilder;
import javafx.beans.property.adapter.JavaBeanProperty;
import javafx.beans.property.adapter.JavaBeanStringProperty;
import javafx.beans.property.adapter.JavaBeanStringPropertyBuilder;
import javax.persistence.CascadeType;
import javax.persistence.MappedSuperclass;
import javax.persistence.OneToOne;
import javax.persistence.Transient;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import org.hibernate.validator.constraints.Email;
import org.hibernate.validator.constraints.NotEmpty;
import org.hibernate.validator.constraints.Range;
import transervfx.Dato.Validacion.ValidacionesNivelLogico;

/**
 *
 * @author oscar
 */
@MappedSuperclass
public abstract class Persona implements Serializable {
    
    private static final long serialVersionUID = 1L;
    
    @Size(min = 4, max = 30, message = "4 letras minimos, 30 maximo", groups = ValidacionesNivelLogico.class)
    private String telCelular1;
    
    @Size(min = 4, max = 30, message = "4 letras minimos, 30 maximo", groups = ValidacionesNivelLogico.class)
    private String telCelular2;
    
    @Size(min = 4, max = 30, message = "4 letras minimos, 30 maximo", groups = ValidacionesNivelLogico.class)
    private String telFijo1;
    
    @Size(min = 4, max = 30, message = "4 letras minimos, 30 maximo", groups = ValidacionesNivelLogico.class)
    private String telFijo2;
    
    @Email(message = "Formato incorrecto", groups = ValidacionesNivelLogico.class)
    private String email;
    
    
    private String condicionFrenteIva;
    
    
    
    private Integer cuit;
    
    
    
    //-+-------------------------------
    //los transient son para q no lo gusrade en la bd
    @Transient
    private JavaBeanStringProperty PROP_TELCELULAR1;
    @Transient
    private JavaBeanStringProperty PROP_TELCELULAR2;
    @Transient
    private JavaBeanStringProperty PROP_TELFIJO1;
    @Transient
    private JavaBeanStringProperty PROP_TELFIJO2;
    @Transient
    private JavaBeanStringProperty PROP_EMAIL;
    
    @Transient
    private JavaBeanIntegerProperty PROP_CUIT;
    @Transient
    private JavaBeanStringProperty PROP_CONDICIONFRENTEIVA;
    
    
    
    //PARA QUE SERVIA EL GROUND???
     @Transient
    private ArrayList<JavaBeanProperty> GroupBindProperties = new ArrayList<>();
 
     //ALL le dice q haga todo por cascada, si actualiza una direccion, o si le cambia el id, lo hace por cascada y
     //la persona sigue con esa direccion, con las modificaciones realizadas,
     //si hace un deleta de la persona, borra en cascada la direccion etc
    
    @OneToOne(cascade = CascadeType.ALL)
    private Domicilio domicilio;

    public String getTelCelular1() {
        return telCelular1;
    }

    public void setTelCelular1(String telCelular1) {
        this.telCelular1 = telCelular1;
    }

    public String getTelCelular2() {
        return telCelular2;
    }

    public void setTelCelular2(String telCelular2) {
        this.telCelular2 = telCelular2;
    }

    public String getTelFijo1() {
        return telFijo1;
    }

    public void setTelFijo1(String telFijo1) {
        this.telFijo1 = telFijo1;
    }

    public String getTelFijo2() {
        return telFijo2;
    }

    public void setTelFijo2(String telFijo2) {
        this.telFijo2 = telFijo2;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getCondicionFrenteIva() {
        return condicionFrenteIva;
    }

    public void setCondicionFrenteIva(String condicionFrenteIva) {
        this.condicionFrenteIva = condicionFrenteIva;
    }

    public Integer getCuit() {
        return cuit;
    }

    public void setCuit(Integer cuit) {
        this.cuit = cuit;
    }

    public Domicilio getDomicilio() {
        return domicilio;
    }

    public void setDomicilio(Domicilio domicilio) {
        this.domicilio = domicilio;
    }

    

    public JavaBeanStringProperty getPROP_TELCELULAR1() throws NoSuchMethodException {
        if (PROP_TELCELULAR1 == null) {
            PROP_TELCELULAR1 = JavaBeanStringPropertyBuilder.create().bean(this).name("telCelular1").build();
            getGroupBindProperties().add(PROP_TELCELULAR1);
        }
        return PROP_TELCELULAR1;
    }

    public JavaBeanStringProperty getPROP_TELCELULAR2() throws NoSuchMethodException {
        if (PROP_TELCELULAR2 == null) {
            PROP_TELCELULAR2 = JavaBeanStringPropertyBuilder.create().bean(this).name("telCelular2").build();
            getGroupBindProperties().add(PROP_TELCELULAR2);
        }
        return PROP_TELCELULAR2;
    }

    public JavaBeanStringProperty getPROP_TELFIJO1() throws NoSuchMethodException {
        if (PROP_TELFIJO1 == null) {
            PROP_TELFIJO1 = JavaBeanStringPropertyBuilder.create().bean(this).name("telFijo1").build();
            getGroupBindProperties().add(PROP_TELFIJO1);
        }
        return PROP_TELFIJO1;
    }

    public JavaBeanStringProperty getPROP_TELFIJO2() throws NoSuchMethodException {
        if (PROP_TELFIJO2 == null) {
            PROP_TELFIJO2 = JavaBeanStringPropertyBuilder.create().bean(this).name("telFijo2").build();
            getGroupBindProperties().add(PROP_TELFIJO2);
        }
        return PROP_TELFIJO2;
    }
  
   
    public JavaBeanStringProperty getPROP_EMAIL() throws NoSuchMethodException {
        if (PROP_EMAIL == null) {
            PROP_EMAIL = JavaBeanStringPropertyBuilder.create().bean(this).name("email").build();
            getGroupBindProperties().add(PROP_EMAIL);
        }
        return PROP_EMAIL;
    }
    
    public JavaBeanIntegerProperty getPROP_CUIT() throws NoSuchMethodException {

        if (PROP_CUIT == null) {
            PROP_CUIT = JavaBeanIntegerPropertyBuilder.create().bean(this).name("cuit").build();
            getGroupBindProperties().add(PROP_CUIT);
        }
        return PROP_CUIT;
    }
    
    public JavaBeanStringProperty getPROP_CONDICIONFRENTEIVA() throws NoSuchMethodException {

        if (PROP_CONDICIONFRENTEIVA == null) {
            PROP_CONDICIONFRENTEIVA = JavaBeanStringPropertyBuilder.create().bean(this).name("condicionFrenteIva").build();
            getGroupBindProperties().add(PROP_CONDICIONFRENTEIVA);
        }
        return PROP_CONDICIONFRENTEIVA;
    }

     public void unbindingALL() {
        for (JavaBeanProperty beanBinding : GroupBindProperties) {
            beanBinding.unbind();
        }
    }

    protected ArrayList<JavaBeanProperty> getGroupBindProperties() {
        return GroupBindProperties;
    }
}
